﻿using Microsoft.Extensions.Logging;
using Salary.Sys.Core.Exceptions;
using Salary.Sys.Core.Procedure;
using Salary.Sys.Core.Threads;

namespace Salary.Sys.Core
{
    public class SalarySys: Infrastructure.SingletonBase<SalarySys>
    {


        #region Singleton
        protected override bool AutoInitialization => false;

        private SalarySys()
        {
            _loggerFactory = new LoggerFactory();
        }

        public override void Initialize()
        {
            //Init logger
            _loggerFactory = LoggerFactory.Create(c => { c.AddConsole(); });
            
            Configuration.Configuration.Instance.EnsureInitialized();
        }

        #endregion

        #region Fields

        private ILoggerFactory _loggerFactory;
        #endregion


        #region Private Methods



        #endregion


        #region Public Methods

        public void RegisterThread<TThread>() where TThread : ThreadBase, new()
        {

        }
        
        public ILogger GetLogger(string name) => _loggerFactory.CreateLogger(name);
        public ILogger<T> GetLogger<T>() => _loggerFactory.CreateLogger<T>();

        #endregion
    }
}
